x86, mce: Dump mce log by ERST when mc panic
authorLiu, Jinsong <jinsong.liu@intel.com>
Sat, 23 Jul 2011 07:56:58 +0000 (08:56 +0100)
committerLiu, Jinsong <jinsong.liu@intel.com>
Sat, 23 Jul 2011 07:56:58 +0000 (08:56 +0100)
We have implemented basic ERST logic before. Now linux3.0 as dom0 has
included APEI logic. Hence it's time to add mce apei interface and
enable APEI ERST feature.
With it, it can save mce log by ERST method when mc panic.

Signed-off-by: Liu, Jinsong <jinsong.liu@intel.com>
xen/arch/x86/cpu/mcheck/mce.c
xen/arch/x86/cpu/mcheck/mce.h
xen/arch/x86/cpu/mcheck/mce_intel.c

index 030fc54070b31b1adfccb33a27a572567beb1996..e6626d98835826511bc538731e906c74fd9f3fe1 100644 (file)
@@ -919,6 +919,28 @@ void *x86_mcinfo_add(struct mc_info *mi, void *mcinfo)
     return buf;
 }
 
+static void x86_mcinfo_apei_save(
+    struct mcinfo_global *mc_global, struct mcinfo_bank *mc_bank)
+{
+    struct mce m;
+
+    memset(&m, 0, sizeof(struct mce));
+
+    m.cpu = mc_global->mc_coreid;
+    m.cpuvendor = boot_cpu_data.x86_vendor;
+    m.cpuid = cpuid_eax(1);
+    m.socketid = mc_global->mc_socketid;
+    m.apicid = mc_global->mc_apicid;
+
+    m.mcgstatus = mc_global->mc_gstatus;
+    m.status = mc_bank->mc_status;
+    m.misc = mc_bank->mc_misc;
+    m.addr = mc_bank->mc_addr;
+    m.bank = mc_bank->mc_bank;
+
+    apei_write_mce(&m);
+}
+
 /* Dump machine check information in a format,
  * mcelog can parse. This is used only when
  * Dom0 does not take the notification. */
@@ -962,8 +984,11 @@ void x86_mcinfo_dump(struct mc_info *mi)
             printk("[%16"PRIx64"]", mc_bank->mc_misc);
         if (mc_bank->mc_status & MCi_STATUS_ADDRV)
             printk(" at %16"PRIx64, mc_bank->mc_addr);
-
         printk("\n");
+
+        if (is_mc_panic)
+            x86_mcinfo_apei_save(mc_global, mc_bank);
+
     next:
         mic = x86_mcinfo_next(mic); /* next entry */
         if ((mic == NULL) || (mic->size == 0))
index 223c17b2b93df007da5ae413f2538db8bc0ba10e..14f7a40d68cf525673c00ed8684520fe3424768c 100644 (file)
@@ -210,4 +210,6 @@ struct mce {
     __u64 mcgcap;   /* MCGCAP MSR: machine check capabilities of CPU */
 };
 
+extern int apei_write_mce(struct mce *m);
+
 #endif /* _MCE_H */
index 0df6d72b938e018d03d64dd862803d6695ca7b9a..d6d4bb99abda55952e4898c4e5d9adfc5e99da9f 100644 (file)
@@ -283,6 +283,7 @@ static int mce_delayed_action(mctelem_cookie_t mctc)
     {
     case MCER_RESET:
         dprintk(XENLOG_ERR, "MCE delayed action failed\n");
+        is_mc_panic = 1;
         x86_mcinfo_dump(mctelem_dataptr(mctc));
         panic("MCE: Software recovery failed for the UCR\n");
         break;